package sqlexplorer.domain.sorting;

import java.util.Comparator;

import sqlexplorer.domain.metadata.ColumnMetaData;


public class ColumnMetadataComparator implements Comparator<ColumnMetaData>{
	
	private SortDirection m_sortDirection;
	
	public ColumnMetadataComparator(SortDirection sortdirection){
		m_sortDirection=sortdirection;
	}
	
	@Override
	public int compare(ColumnMetaData o1,ColumnMetaData o2){
		int val=o1.getColumnName().compareTo(o2.getColumnName());
		
		if(m_sortDirection.equals(SortDirection.ASCENDING)){
			return val;
		}else{
			return (val*(-1));
		}
	}
}
